<?php
declare (strict_types = 1);

namespace app\model;

use app\tool\Date;
use think\Model;
use think\model\concern\SoftDelete;

/**
 * @property array $content
 * @property int $forum_id
 * @property int $id
 * @property int $like
 * @property int $pid
 * @property int $to_users_id
 * @property int $users_id
 * @property string $city
 * @property string $createtime
 * @property string $ip
 * @property-read \app\model\ForumComment[] $comment
 * @property-read \app\model\Users $to_users
 * @property-read \app\model\Users $users
 * @property-read \app\model\UsersLike $users_like
 * @property-read mixed $create_time
 * @mixin \think\Model
 */
class ForumComment extends Model
{
	use SoftDelete;
	
	protected $createTime = 'createtime';
	protected $deleteTime = 'deletetime';

    protected $type = [
        'content'=>'json',
    ];
    public function users()
    {
        return $this->belongsTo(Users::class, 'users_id');
    }

    public function toUsers()
    {
        return $this->belongsTo(Users::class, 'to_users_id');
    }

    function comment()
    {
        return $this->hasMany(ForumComment::class,'pid');
    }

    public function usersLike()
    {
        return $this->hasOne(UsersLike::class,'pro_id');
    }

    function getCreateTimeAttr($value)
    {
        return Date::human($value);
    }
}
